#!/usr/bin/evn python
# coding:utf-8
import os
import numpy as np

try:
    import xml.etree.cElementTree as ET
except ImportError:
    import xml.etree.ElementTree as ET
import sys

path = "./UW20170906/Annotations/"
for root, dirs, files in os.walk(path, topdown=False):
    print(files)
for file in files:
    # print(os.path.join(root, file))
    f = os.path.join(root, file)
    name = file.split('.')
    filename = name[0]
    tree = ET.parse(f)  # 打开xml文档
    root_node = tree.getroot()  # 获得root节点
    root_node.find('filename').text=filename
    print(filename)
    write_path = path + file
    tree.write(write_path)
